<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>选择你喜欢的鼠标</title>
    <style>
        *{font-size: 16px; font-family: "Arial", "微软雅黑"; line-height: 25px;}
        div{
            padding: 5px; text-align: center;
            width: 300px;
            display: inline;
        }
        img{
            width: 300px;
        }
        div span{display: block;}
        .mouse-title{
            font-size: 20px;
        } 
        
    </style>
</head>
<body>
<p> <span class="mouse-title">选择你喜欢的鼠标：</span> <br><input type="radio" name="mouse" onclick="mouse()">罗技——轨迹球<br> <input type="radio" name="mouse" onclick="mouse()">雷蛇——游戏鼠</p>
<div><img src="" alt="" id="image" onclick="img()"><span></span></div>
<script>
    function mouse(){
        var ele=document.getElementsByName("mouse");
        var img=document.getElementById("image");  // 
        if(ele[0].checked){  // 判断 单选框 复选框 是否选中
            img.setAttribute("src","images/gj.jpg");
            img.setAttribute("alt","罗技——轨迹球");
            img.nextSibling.innerHTML="罗技——轨迹球";
        }
        else if(ele[1].checked){
            img.setAttribute("src","images/ls.jpg");
            img.setAttribute("alt","雷蛇——游戏鼠");
            img.nextSibling.innerHTML="雷蛇——游戏鼠";
        }
    }
    function img(){
        var alt=document.getElementById("image").getAttribute("alt");
        alert("alt属性值："+alt)
    }
</script>
</body>
</html>